package com.work.formaldehyde.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.umeng.analytics.MobclickAgent;
import com.work.formaldehyde.R;
import com.work.formaldehyde.util.ApiUtils;


public class TuiKuanJinDuActivity extends Activity implements View.OnClickListener {
    private ImageView comeback;
    private ImageView tuihuoone, tuihuotwo, tuihuothree, gouwuche_img;
    private View view1, view2;
    private TextView tuikuanjintext, shangpingmingzi, tkyy, tkje, sqsj, tkbm,jujue;
    private TextView tuihuoone_text, tuihuotwo_text;
    private String cause;
    private LinearLayout jujueliyou;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ApiUtils.ActivityIsLogin(this, 1);
        setContentView(R.layout.activity_huotuixiangqing);
        comeback = findViewById(R.id.querendingdan_comeback);
        comeback.setOnClickListener(this);
        if (ApiUtils.isNetworkConnected(TuiKuanJinDuActivity.this))
            init();
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    public String gettype = "";

    /**
     * 初始加载
     */
    public void init() {
        Intent getstr = getIntent();
        gettype = getstr.getStringExtra("gettype");
        tuihuoone_text = findViewById(R.id.tuihuoone_text);
        tuihuotwo_text = findViewById(R.id.tuihuotwo_text);
        tuikuanjintext = findViewById(R.id.tuikuanjintext);
        jujue=findViewById(R.id.jujue);
        jujueliyou=findViewById(R.id.jujueliyou);
        tuikuanjintext.setText(getstr.getStringExtra("tkje") + "元");
        shangpingmingzi = findViewById(R.id.shangpingmingzi);
        shangpingmingzi.setText(getstr.getStringExtra("shangpingmingzi"));
        cause=getstr.getStringExtra("cause");
        tkyy = findViewById(R.id.tkyy);
        tkyy.setText(getstr.getStringExtra("tkyy"));
        tkje = findViewById(R.id.tkje);
        tkje.setText(getstr.getStringExtra("tkje") + "元");
        sqsj = findViewById(R.id.sqsj);
        sqsj.setText(getstr.getStringExtra("sqsj"));
        tkbm = findViewById(R.id.tkbm);
        tkbm.setText(getstr.getStringExtra("tkbm"));
        view1 = findViewById(R.id.view1);
        view2 = findViewById(R.id.view2);
        tuihuoone = findViewById(R.id.tuihuoone);
        tuihuotwo = findViewById(R.id.tuihuotwo);
        tuihuothree = findViewById(R.id.tuihuothree);
        if (gettype.equals("0")) {
            view1.setBackgroundColor(getResources().getColor(R.color.back_view));
            view2.setBackgroundColor(getResources().getColor(R.color.back_view));
            tuihuoone.setImageResource(R.mipmap.wl);
            tuihuotwo.setImageResource(R.mipmap.wls);
            tuihuothree.setImageResource(R.mipmap.wls);
            tuihuoone_text.setText("买家申请\n" + getstr.getStringExtra("sqsj").substring(0, 10));
        }
        if (gettype.equals("1")) {
            view1.setBackgroundColor(getResources().getColor(R.color.design_default_color_primary));
            view2.setBackgroundColor(getResources().getColor(R.color.back_view));
            tuihuoone.setImageResource(R.mipmap.wl);
            tuihuotwo.setImageResource(R.mipmap.wl);
            tuihuothree.setImageResource(R.mipmap.wls);
            tuihuoone_text.setText("买家申请\n" + getstr.getStringExtra("sqsj").substring(0, 10));
            tuihuotwo_text.setText("卖家退款\n" + getstr.getStringExtra("tksj").substring(0, 10));
        }
        if (gettype.equals("2")) {
            view1.setBackgroundColor(getResources().getColor(R.color.design_default_color_primary));
            view2.setBackgroundColor(getResources().getColor(R.color.design_default_color_primary));
            tuihuoone.setImageResource(R.mipmap.wl);
            tuihuotwo.setImageResource(R.mipmap.wl);
            tuihuothree.setImageResource(R.mipmap.wl);
            tuihuoone_text.setText("买家申请\n" + getstr.getStringExtra("sqsj").substring(0, 10));
            tuihuotwo_text.setText("卖家退款\n" + getstr.getStringExtra("tksj").substring(0, 10));
        }
        if (gettype.equals("3")) {
            view1.setBackgroundColor(getResources().getColor(R.color.design_default_color_primary));
            view2.setBackgroundColor(getResources().getColor(R.color.back_view));
            tuihuoone.setImageResource(R.mipmap.wl);
            tuihuotwo.setImageResource(R.mipmap.wl);
            tuihuothree.setImageResource(R.mipmap.wls);
            tuihuoone_text.setText("买家申请\n" + getstr.getStringExtra("sqsj").substring(0, 10));
            tuihuotwo_text.setText("卖家拒绝\n" + getstr.getStringExtra("tksj").substring(0, 10));
            jujueliyou.setVisibility(View.VISIBLE);
            jujue.setText(cause);
        }
        gouwuche_img = findViewById(R.id.gouwuche_img);
        ApiUtils.GET_IMAGE(TuiKuanJinDuActivity.this, getstr.getStringExtra("gouwuche_img"), gouwuche_img);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.querendingdan_comeback:
                onBackPressed();
                break;

        }
    }

    public boolean onKeyUp(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                onBackPressed();
                break;
        }
        return super.onKeyUp(keyCode, event);
    }


}
